﻿using HandyControl.Controls;
using System;
using System.ComponentModel;
using System.Windows;

namespace LpbPrj.Client.Controls;

public class PropertyExItem : PropertyItem
{
    /// <summary>
    /// 组内排序
    /// </summary>
    public static readonly DependencyProperty DisplayOrderProperty = DependencyProperty.Register(nameof(DisplayOrder), typeof(int), typeof(PropertyExItem), new PropertyMetadata(0));
    public int DisplayOrder
    {
        get => (int)GetValue(DisplayOrderProperty);
        set => SetValue(DisplayOrderProperty, value);
    }

    /// <summary>
    /// 分组排序
    /// </summary>
    public static readonly DependencyProperty CategoryOrderProperty = DependencyProperty.Register(nameof(CategoryOrder), typeof(int), typeof(PropertyExItem), new PropertyMetadata(0));
    public int CategoryOrder
    {
        get => (int)GetValue(CategoryOrderProperty);
        set => SetValue(CategoryOrderProperty, value);
    }
}


[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class, AllowMultiple = false)]
public sealed class DisplayOrderAttribute : DefaultValueAttribute
{
    public DisplayOrderAttribute(int order = int.MaxValue) : base(order)
    {
    }

    public int Order => base.Value != null ? (int)base.Value : int.MaxValue;

}


[AttributeUsage(AttributeTargets.Property | AttributeTargets.Class, AllowMultiple = false)]
public sealed class CategoryOrderAttribute : DefaultValueAttribute
{
    public CategoryOrderAttribute(string category, int order = int.MaxValue) : base(order)
    {
        Category = category;
    }

    public string Category { get; }
    public int Order => base.Value != null ? (int)base.Value : int.MaxValue;

}
